package gui;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.*;

import bot.*;

public class PopulationButton extends JButton{
	
	/**
	 * Default Serialization
	 */
	private static final long serialVersionUID = 1L;
	private JTextField url;
	public PopulationButton(JTextField urlText){
		super("Population");
		url = urlText;
		
//		addActionListener(new ActionListener(){
//			@Override
//			public void actionPerformed(ActionEvent arg0){
//				City choosen = new City(BotGui.demo, BotGui.area, Util.parseName(url.getText()));
//				Util.setPasteBuffer(choosen.getTotalPopulation());
//			}
//		});
//		
//		addKeyListener(new KeyListener(){
//			@Override
//			public void keyPressed(KeyEvent arg0) {
//				if (arg0.getKeyChar() == 'v'){
//					City choosen = new City(BotGui.demo, BotGui.area, Util.parseName(url.getText()));
//					Util.setPasteBuffer("The population was " + choosen.getTotalPopulation() + " at the [[2010 United States Census|2010 census]]");
//				}
//			}
//			@Override
//			public void keyReleased(KeyEvent arg0) {
//			}
//			@Override
//			public void keyTyped(KeyEvent arg0) {
//			}
//		});
		addMouseListener(new MouseListener() {
			@Override
			public void mouseReleased(MouseEvent arg0) {
			}
			@Override
			public void mousePressed(MouseEvent arg0) {
			}
			@Override
			public void mouseExited(MouseEvent arg0) {
			}
			@Override
			public void mouseEntered(MouseEvent arg0) {
			}
			@Override
			public void mouseClicked(MouseEvent arg0) {
				if (arg0.getButton() == MouseEvent.BUTTON1){
					City choosen = new City(url.getText(), BotGui.data);
					Util.setPasteBuffer(choosen.getTotalPopulation());
				}
				else{
					City choosen = new City(url.getText(), BotGui.data);
					Util.setPasteBuffer("The population was " + Util.smallNumberCheck(choosen.getTotalPopulation()) + " at the [[2010 United States Census|2010 census]].");
				}
			}
		});
	}
}
